const datetime = () => {
  var date = new Date()
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const sencond = date.getSeconds()

  return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, sencond].map(formatNumber).join(':')
}

const date = () => {
  var date = new Date()
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()

  return [year, month, day].map(formatNumber).join('-')
}

const startDate = () => {
  var date = new Date()
  date.setTime(date.getTime() + 24 * 60 * 60 * 1000)
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()

  return [year, month, day].map(formatNumber).join('-')
}

const endDate = () => {
  var date = new Date()
  date.setTime(date.getTime() + 30 * 24 * 60 * 60 * 1000)
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()

  return [year, month, day].map(formatNumber).join('-')
}

const time = () => {
  var date = new Date()
  const hour = date.getHours()
  const minute = date.getMinutes()

  return [hour, minute].map(formatNumber).join(':')
}


const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}

module.exports = {
  datetime,
  date,
  time,
  startDate,
  endDate
}